#include "lldi.h"
ld::ld()
{
    
}

ld::~ld(){}

void ld::Insd_P()
{
    ref q;
    q=new Tnod;
    cout<<"Info:";
    cin>>q->info;
    q->next=NULL;
    q->prev=NULL;
    nod_prim=q;
}

void ld::Insd_Cf(void)
{
    ref q;
    q=new Tnod;
    cout<<"Info:";
    cin>>q->info;
    q->next=nod_prim;
    nod_prim->prev=q;
    nod_prim = q;
}
void ld::readList()
{
    Insd_P();
    char c;
    cout<<"Add? y/n";
    cin>>c;
    while (c=='y')
    {
        Insd_Cf();
        cout<<"Add? y/n";
        cin>>c;
    }
}
void ld::print()
{
    ref r;
    r = nod_prim;
    while(r != NULL)
    {
        cout<<"Info = "<<r->info<<endl;
        r = r->next;
    }
    cout<<"End of List";
}
bool ld::operator==(ld list)
{
    ref r=this->nod_prim, q=list.nod_prim;
    while (r!=NULL && q!=NULL)
    {
        if (r->info != q->info)
            return  false;
        else r=r->next,q=q->next;
    }
    if (r==NULL && q==NULL)
        return true;
    else return false;
}

bool ld::operator!=(ld list)
{
    ref r=this->nod_prim, q=list.nod_prim;
    while (r!=NULL && q!=NULL)
    {
        if (r->info != q->info)
            return  true;
        else r=r->next,q=q->next;
    }
    if (r==NULL && q==NULL)
        return false;
    else return true;
}

ld ld::operator+(Tnod n)
{
    ref q;
    q=new Tnod;
    q->info=n.info;
    q->next=nod_prim;
    nod_prim->prev=q;
    nod_prim=q;
    return *this;
}
ld ld::operator+(int x)
{
    ref q;
    q=new Tnod;
    q->info=x;
    q->next=nod_prim;
    nod_prim->prev=q;
    nod_prim=q;
    return *this;
}
ld ld::operator+(ld list)
{
    ref r=this->nod_prim, q=list.nod_prim;
    while (r->next!=NULL)
        r=r->next;
    r->next=q;
    q->prev=r;
    return *this;
}